<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/6
 * Time: 11:24
 */

namespace app\admin\controller;


use cmf\controller\AdminBaseController;
use think\Db;

/**
 * Class TheatreController
 * @package app\admin\controller
 * 一合说法模块
 */
class StatementController extends AdminBaseController
{

    protected $arrWhere = [];
    /**
     * 小剧场
     */
    public function theatre()
    {
        $title = trim(request()->param('title'));
        if(!empty($title)){
            $this->arrWhere['title'] = ['like',"%$title%"];
        }
        $theatre = Db::name('theatre')->where($this->arrWhere)->order('create_time desc')->paginate(8);
        $pages = $theatre->render();

        return view('',['theatre'=>$theatre,'page'=>$pages]);
    }

    /**
     * 小剧场-添加视频
     */
    public function add_theatre()
    {
        if(request()->isPost()){
            $data = request()->param();
            $data['create_time'] = time();
            $res = Db::name('theatre')->insert($data);
            if($res){
                $this->success('添加成功!', url('Statement/theatre'));
            }else{
                $this->error('添加成功！',url('Statement/theatre'));
            }
        }
        return view();
    }


    /**
     * 小剧场-删除视频
     */
    public function theatre_del()
    {
        $id = request()->param('id');
        if (Db::name('theatre')->delete($id) !== false) {
            $this->success("删除成功！");
        } else {
            $this->error("删除失败！");
        }
    }

}